package org.jaaksi.customviewdemo.roundview

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView

/**
 * 1.支持Ripple，默认开，默认颜色为White
 * 2.支持圆角、圆形，需要使用rv_backgroundColor
 * 3.支持边框
 * 4.支持自适应缩放
 *
 */
class DJRoundTextView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : AppCompatTextView(
    context, attrs, defStyleAttr
), IRoundViewDelegate {
    private val delegate = RoundViewDelegate(this, attrs)

    override fun getRoundDelegate() = delegate

    override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
        super.onLayout(changed, left, top, right, bottom)
        delegate.checkAndSetBackground()
    }
}